﻿using Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Script.Human.Player.Action
{
    public class RunAction :BasePlayerAction, IAction
    {
        InputReaderMan readerMan;
        public RunAction(PlayerBody playerBody) : base(playerBody)
        {
            readerMan = InputRead.GetID();
        }

        public void Interrupt()
        {
            playerState.Move = false;
            //animator.SetFloat("Move", 1);
        }

        public void OnEnter(ref object[] o)
        {
        }


        public void OnFixedUpdate()
        {
            
        }

        public void OnUpdate()
        {
            var v3 = Vector3.zero;
            v3.x = readerMan.HorizontalAxis;
            v3.y = readerMan.VerticalAxis;
            if (v3 != Vector3.zero)
            {
                playerBody.transform.Translate(v3.normalized * playerData.RunSpeed * Time.deltaTime, Space.World);
                playerState.Move = true;
                //animator.SetFloat("Move", 1);
            }
            else
            {
                playerState.Move = false;
                //animator.SetFloat("Move", 0);
            }
        }
    }
}
